Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP -- How would we hide the display on /tests/$id#settings pages? -- Add support for configurable secrets variables #5691

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

okurz
Copy link
Member

@okurz okurz commented Jun 11, 2024

@okurz okurz marked this pull request as draft June 11, 2024 14:25
sub redact_settings ($vars) {
return {map { $_ !~ qr/(^_SECRET_|_PASSWORD)/ ? ($_ => $vars->{$_}) : ($_ => '[redacted]') } keys %$vars};
my $hide_re = '^_SECRET_|_PASSWORD';
$hide_re .= "|$vars->{_HIDE_MATCH_RE}" if $vars->{_HIDE_MATCH_RE};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would make it a separate regex and also handle errors in case _HIDE_MATCH_RE doesn't contain a valid regex (in which case our default regexes should at least still be applied but some kind of user visible error would be great as well).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be a bit more verbose with the variable name:

Suggested change
$hide_re .= "|$vars->{_HIDE_MATCH_RE}" if $vars->{_HIDE_MATCH_RE};
$hide_re .= "|$vars->{_HIDE_SECRETS_REGEX}" if $vars->{_HIDE_SECRETS_REGEX};

(This is clearer then the abbreviation "re". Considering we are hiding secrets here I would replace "match" with "secrets".)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both suggestions covered including the fallback to ignore the additional custom stuff and still apply the default. I am still doing a concatenation to form the final regex. With more procedural code we could also use if /$default_re/ || /$custom_re/ but IMHO it wouldn't be better. WDYT?

… Add support for configurable secrets variables

Related progress issue: https://progress.opensuse.org/issues/162086
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants